home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
kermit.columbia.edu
/
kermit.columbia.edu.tar
/
kermit.columbia.edu
/
newsgroups
/
misc.20020314-20021006
/
000258_fdc@columbia.edu_Fri Aug 2 10:11:23 EDT 2002.msg
< prev
next >
Wrap
Text File
|
2002-10-06
|
5KB
|
109 lines
Article: 13574 of comp.protocols.kermit.misc
Path: newsmaster.cc.columbia.edu!news.columbia.edu!news-not-for-mail
From: fdc@columbia.edu (Frank da Cruz)
Newsgroups: comp.protocols.kermit.misc
Subject: Re: Renaming a file after receiving
Date: 2 Aug 2002 10:11:09 -0400
Organization: Columbia University
Lines: 92
Message-ID: <aie3tt$gch$1@watsol.cc.columbia.edu>
References: <d49c50d5.0208011551.2aeed298@posting.google.com>
NNTP-Posting-Host: watsol.cc.columbia.edu
X-Trace: newsmaster.cc.columbia.edu 1028297471 25070 128.59.39.139 (2 Aug 2002 14:11:11 GMT)
X-Complaints-To: postmaster@columbia.edu
NNTP-Posting-Date: 2 Aug 2002 14:11:11 GMT
Xref: newsmaster.cc.columbia.edu comp.protocols.kermit.misc:13574
In article <d49c50d5.0208011551.2aeed298@posting.google.com>,
Luke Weese <hairyveggie@yahoo.com> wrote:
: Hi. So we all know, I am a newbie to C-Kermit scripting. I have
: written some scripts to dial in to a Wildcat BBS system, choose some
: menu options, and receive a file using the Zmodem protocol (they
: support Kermit protocol, but they highly recommend Zmodem because they
: obviously havent read the Performance chapter in the Kermit manual,
: judging by the 3.8% efficiency of the download). All of this goes
: through fine, but the only problem I had is that when using Zmodem,
: the "as-name" argument to the receive command is apparently ignored.
:
Because Zmodem is an external program. In this scenario a file arrives
and Zmodem receives it. Kermit doesn't know the name of the file, so
has no way to rename it. This probably should be clarified in the
documentation.
: I worked around this with some rather silly scripting involving
: redirecting an "ls" command, parsing the filename and renaming, but I
: was hoping someone could suggest a less clumsy way to rename the
: downloaded file. Here's the excerpt of my script:
:
: -------------START----------------
: mkdir tmpdir ; Make "tmpdir" to store this download
: if fail goto mkdirfailed ; Bail if permissions messed up
: cd tmpdir ; Move into "tmpdir"
:
: set take error on ; Set the error detection
:
This is the default anyway.
: set terminal autodownload off ; Turn auto download off
:
: set protocol zmodem rz {rz -a} {sz %s} {sz -a %s} rz {rz -a} ; Use Zmodem
:
So far so good. Btw, "set protocol zmodem" is sufficient -- the additional
parameters are the default ones for Zmodem anyway.
: -------------DIALING, etc...------
:
: receive hndyinvc.dat ; Download the file
: If fail goto downloadfailure ; Error receiving file
:
At this point you should have only newly downloaded files in your directory,
since you just created and cd'd to it.
: .\%x := \Ffiles(*) ; Count the files in tmpdir
: If = 1 \%x ls > ../dir.txt ; If only 1, list to parent dir
: else goto oldfilesoutthere ; More than one file, bail
:
This could happen if Zmodem received more than one file.
: cd .. ; Go back to "hndmodem"
: open read dir.txt ; Open list file
: if fail goto nodirfile ; Bail if nonexistent
:
: read \%o ; Read first line, "total n"
: if fail goto nodirfile ; Bail if nonexistent
: read \%o ; Read 2nd line with filename
: if fail goto nodirfile ; Bail if nonexistent
:
: .\%d := \Fsubstring(\%o,57) ; Get filename from pos 57 on
: cd tmpdir ; Go back to "tmpdir"
: If exist \%d mv \%d ../hndyinvc.dat ; If there, move back & rename
: cd .. ; Go back to "hndmodem"
:
: rmdir tmpdir ; Remove "tmpdir" for next time
: If fail echo Could not remove "tmpdir" automatically. Please remove manually.
: rm dir.txt ; Remove "dir.txt"
: If fail echo Could not remove "dir.txt" automatically. Pls remove manually.
:
: ------------FINISH----------------
:
: Please excuse any newbie mistakes in the coding, but feel free to
: point them out. Thanks in advance for any help.
:
\ffiles() not only returns the number of files that match its argument
pattern, but also builds a list of files that you can cycle through with
\fnextfile(), so you don't have to run an external directory-listing program
or parse its output:
if > \Ffiles(*) 1 stop 1 Multiple files received.
.filename := \fnextfile()
rename \m(filename) ../hndyinvc.dat
if fail stop 1 rename \m(filename) ../hndyinvc.dat failed.
cd ..
rmdir tmpdir
If fail stop 1 rmdir \v(dir)tmpdir failed.
Assigning \fnextfile() to a variable is necessary because every time you
refer to \fnextfile() it returns the next filename.
- Frank